<template>
	<div class="postform">
		<Form>
			<div v-if="datas.length == 0" style="width: 100%;text-align: center;color: #FF0000;">表单</div>
			<Render v-for="(item,index) in datas" :key="index" :conf="item || {}"></Render>
		</Form>
		<div class="postform-button" v-if="button">
			<Button color="primary">提交</Button>
			<Button>取消</Button>
		</div>
	</div>
</template>
 
<script>
	import {Render} from '@/components/custom-form'
	export default {
		components: {
			Render
		},
		props: {
			form_id : Number,
			button : {
				type : Boolean,
				default : false
			}
		},
		data() {
			return {
				datas : []
			}
		},
		watch:{
			'form_id'(){
				this.loadData()
			}
		},
		mounted() {
			this.loadData()
		},
		methods: {
			loadData() {
				if(this.form_id > 0){
					this.datas = this.$global.getArrayById(this.$global.config.forms,this.form_id,'data') || []
				}
			}
		}
	}
</script>

<style lang='less'>
	.postform{
		background-color:#fff;
		.postform-button{
			display: flex;
			padding: 5px;
			justify-content:space-between;
			line-height: 25px;
		}
	}
</style>
